<div class="stories form container">
	
	<h2><?php echo __d('admin', 'Create Product'); ?></h2>

<?php
	$formOptions = array (
		'type' => 'file',
		'inputDefaults' => array (
			'div' => array('class' => 'form-group'),
		)
	);
	
	$formElements = array (
		'title' => array(
			'class' => 'form-control input-lg', 
			'placeholder' => __('Enter title here')
		),
		'description' => array(
			'class' => 'form-control input-lg'
		),
		'Picture.file' => array(
			'type' => 'file',
			'label' => __('Picture'),
			'after' => '<p class="help-block">' . __d('admin', 'Upload an image from your computer') . '</p>'
		),
		'quantity' => array(
			'class' => 'form-control input-sm',
			'default' => 0
		),
		'price' => array(
			'class' => 'form-control input-sm', 
			'default' => '0.0',
		),
		'home_deliver' => array (
			'type' => 'checkbox',
			'label' => false,
			'before' => '<div class="checkbox"><span class="glyphicon glyphicon-home"></span> <label>' . __d('admin', 'home-delivered?'),
			'after' => '</label></div>',
			'value' => 'Y'
		),
		'is_promotion' => array (
			'type' => 'checkbox',
			'label' => false,
			'before' => '<div class="checkbox"><span class="glyphicon glyphicon-certificate"></span> <label>' . __('promotion?'),
			'after' => '</label></div>',
			'value' => 'Y'
		)
	);
?>
	<?php echo $this->Form->create('Product', $formOptions); ?>
		<div class="row row-offcanvas row-offcanvas-right">

			<div class="col-xs-12 col-sm-8">
				<?php 
					foreach($formElements as $name => $options) {
						echo $this->Form->input($name, $options) . "\n\n";
					}
					echo $this->Form->submit(__('Create'), array('class' => 'btn btn-primary'));
				?>
			</div>

			<div class="col-xs-12 col-sm-4 sidebar-offcanvas" id="sidebar" role="navigation">
				<!-- User -->
				<div class="panel panel-default">
					<div class="panel-heading"><b>User</b></div>
					<div class="panel-body">
						<div class="form-group">
							<?php echo $this->Form->input('user_id', array('class' => 'form-control input-sm', 'label' => false)); ?>
						</div>
						<p>
							<a href="#ModalCreateUser" class="btn btn-link" data-toggle="modal">
								<span class="glyphicon glyphicon-plus"></span> <?php echo __d('admin', 'Add New User'); ?>
							</a>
						</p>
					</div>
				</div>
				<!-- Category -->
				<div class="panel panel-default">
					<div class="panel-heading"><b><?php echo __d('admin', 'Category'); ?></b></div>
					<div class="panel-body">
						<div class="form-group">
							<?php echo $this->Form->input('category_id', array (
								'label' => false,
								'class' => 'form-control input-sm',
								'empty' => __d('admin', 'Uncategorized'),
								'escape' => false
							)); ?>
						</div>
						<p>
							<a href="#ModalCreateCategory" class="btn btn-link" data-toggle="modal"><span class="glyphicon glyphicon-plus"></span> Add New Category</a>
						</p>
					</div>
				</div>
			</div>
		</div>
	<?php echo $this->Form->end(); ?>
	
</div>

<?php 
	// dialogs
	echo $this->element('Users/dialog_create_user');
	echo $this->element('Products/dialog_create_category');
?>

<script>
	$( document ).ready(function() {
		$( "#ProductCreateForm" ).submit(function() {
			// get data from the WYSIWYG editor.
			$( "#inputDescription" ).val( $("#editorDescription").html() );
		});
	});
</script>